home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2005 August / DPPCPRO0805.ISO / Assets / Interface / Main.dxr / Flash Components_1_Centre pane.swf / scripts / __Packages / IntroPage.as < prev    next >
Encoding:
Text File  |  2005-05-20  |  13.6 KB  |  364 lines

  1. class IntroPage extends mx.core.UIObject
  2. {
  3.    var __title;
  4.    var __priDesc;
  5.    var __highlight1;
  6.    var __highlight2;
  7.    var __numHighlights;
  8.    var __preloadsFinished;
  9.    var __preloadsInterval;
  10.    var __highlightListener;
  11.    var __secDesc;
  12.    var __secList;
  13.    var dispatchEvent;
  14.    static var symbolName = "IntroPage";
  15.    static var symbolOwner = IntroPage;
  16.    var className = "IntroPage";
  17.    static var version = "0.0.0.1";
  18.    static var __maxPageHeight = 405;
  19.    static var __pageBorder = 5;
  20.    static var __vSpacing = 5;
  21.    static var __hSpacing = 5;
  22.    var __nextDepth = 1;
  23.    function IntroPage()
  24.    {
  25.       super();
  26.       mx.events.EventDispatcher.initialize(this);
  27.    }
  28.    function set enabled(activeStatus)
  29.    {
  30.       if(activeStatus == true)
  31.       {
  32.          var _loc3_ = "<headline>" + this.__title.htmlText.slice(18,this.__title.htmlText.length - 19) + "</headline>";
  33.          var _loc2_ = new TextFormat();
  34.          _loc2_.color = 0;
  35.          this.__title.setTextFormat(_loc2_);
  36.          this.__title.setNewTextFormat(_loc2_);
  37.          this.__title.htmlText = _loc3_;
  38.          trace("new title: " + _loc3_);
  39.       }
  40.       else
  41.       {
  42.          _loc3_ = "<headlinedisabled>" + this.__title.htmlText.slice(10,this.__title.htmlText.length - 11) + "</headlinedisabled>";
  43.          _loc2_ = new TextFormat();
  44.          _loc2_.color = 8421504;
  45.          this.__title.setTextFormat(_loc2_);
  46.          this.__title.setNewTextFormat(_loc2_);
  47.          this.__title.htmlText = _loc3_;
  48.          trace("new title: " + _loc3_);
  49.       }
  50.       this.__priDesc.enabled = activeStatus;
  51.       this.__highlight1.enabled = this.__highlight2.enabled = activeStatus;
  52.    }
  53.    function init(Void)
  54.    {
  55.       super.init();
  56.    }
  57.    function size(Void)
  58.    {
  59.       super.size();
  60.    }
  61.    function doneSetting()
  62.    {
  63.       if(this.__numHighlights == 0 || this.__numHighlights == undefined)
  64.       {
  65.          this.sendMessage("pageReady");
  66.       }
  67.       else if(this.__numHighlights == this.__preloadsFinished)
  68.       {
  69.          if(this.__preloadsInterval != undefined)
  70.          {
  71.             clearInterval(this.__preloadsInterval);
  72.          }
  73.          this.sendMessage("pageReady");
  74.       }
  75.       else
  76.       {
  77.          this.__preloadsInterval = setInterval("doneSetting",500);
  78.       }
  79.    }
  80.    function set title(newTitle)
  81.    {
  82.       function workingLayout(bodyText, width, targetObject)
  83.       {
  84.          trace("targetObject: " + targetObject);
  85.          var titleFormat = _level0.styleSheetToTextFormat(_global.textStyles.getStyle("headline"));
  86.          targetObject.html = true;
  87.          with(targetObject)
  88.          {
  89.             embedFonts = true;
  90.             setTextFormat(titleFormat);
  91.             setNewTextFormat(titleFormat);
  92.             styleSheet = _global.textStyles;
  93.             border = false;
  94.             selectable = false;
  95.             autoSize = true;
  96.             borderColor = 13421772;
  97.             multiline = true;
  98.             wordWrap = true;
  99.          }
  100.          var oneRowMetrics = titleFormat.getTextExtent("a",width);
  101.          var twoRowMetrics = titleFormat.getTextExtent("a\na",width);
  102.          var tfhIncrement = twoRowMetrics.textFieldHeight - oneRowMetrics.textFieldHeight;
  103.          var metrics = titleFormat.getTextExtent(bodyText,width);
  104.          var finalHtmlText = "<headline><textformat leading=\'" + myLeading + "\'>" + bodyText + "</textformat></headline>";
  105.          targetObject.htmlText = finalHtmlText;
  106.          var positiveLeading = myLeading >= 0 ? myLeading : - myLeading;
  107.          var calculatedHeight = targetObject._height;
  108.          targetObject.autoSize = false;
  109.          targetObject._height = metrics.textFieldHeight + 1;
  110.          targetObject.htmlText = "<headline><textformat leading=\'0\'>" + bodyText + "</textformat></headline>";
  111.          var unleadedTextHeight1 = targetObject.textHeight;
  112.          var unleadedFieldHeight = targetObject._height;
  113.          targetObject.htmlText = "<headline><textformat leading=\'-1\'>" + bodyText + "</textformat></headline>";
  114.          var unleadedTextHeight2 = targetObject.textHeight;
  115.          var numRows = unleadedTextHeight2 - unleadedTextHeight1;
  116.          numRows = numRows >= 0 ? numRows : - numRows;
  117.          trace("numRows of text: " + numRows);
  118.          targetObject.htmlText = finalHtmlText;
  119.          targetObject._height = unleadedFieldHeight + (numRows - 1) * myLeading;
  120.       }
  121.       this.createTextField("__title",this.__nextDepth,IntroPage.__pageBorder,IntroPage.__pageBorder,365,50);
  122.       this.__nextDepth = this.__nextDepth + 1;
  123.       var myLeading = -5;
  124.       var titleFormat = _level0.styleSheetToTextFormat(_global.textStyles.getStyle("headline"));
  125.       workingLayout(newTitle,365,this.__title);
  126.    }
  127.    function set primaryDescription(newDesc)
  128.    {
  129.       trace("PRIMARYDESCRIPTION");
  130.       trace("IntroPage instance received primaryDescription: " + newDesc);
  131.       if(this.__priDesc == undefined)
  132.       {
  133.          this.__priDesc = this.createClassObject(mx.controls.TextArea,"primaryDesc",this.__nextDepth);
  134.          this.__priDesc.editable = false;
  135.          this.__priDesc.label.selectable = false;
  136.          this.__priDesc.wordWrap = true;
  137.          this.__priDesc.html = true;
  138.          this.__priDesc.borderStyle = "none";
  139.          this.__priDesc.embedFonts = true;
  140.          this.__priDesc.styleSheet = _global.textStyles;
  141.          this.__priDesc.setStyle("themeColor","0x005BAB");
  142.          this.__priDesc.setStyle("styleName","scrollTextAreaStyle");
  143.          this.__nextDepth = this.__nextDepth + 1;
  144.       }
  145.       if(this.__priDesc.text != newDesc)
  146.       {
  147.          this.__priDesc.text = "<boxdesc>" + newDesc + "</boxdesc>";
  148.          this.__priDesc._x = IntroPage.__pageBorder;
  149.          this.__priDesc._y = this.__title._y + this.__title.height + 2 * IntroPage.__vSpacing - 16;
  150.          var _loc6_ = undefined;
  151.          _loc6_ = this.__priDesc.styleSheet._styles.pagebody.getTextExtent(this.removeHTMLTags(newDesc),365);
  152.          if(_loc6_.textFieldHeight > 100)
  153.          {
  154.             var _loc7_ = _loc6_.ascent + _loc6_.descent;
  155.             var _loc3_ = _loc7_ + 2;
  156.             var _loc4_ = 96 - _loc7_;
  157.             var _loc5_ = 0;
  158.             while(_loc4_ > _loc3_)
  159.             {
  160.                _loc5_ = _loc5_ + 1;
  161.                _loc4_ -= _loc3_;
  162.             }
  163.             var _loc9_ = 4 + _loc7_ + _loc5_ * _loc3_;
  164.             this.__priDesc.setSize(365,_loc7_ + _loc5_ * _loc3_ + 4);
  165.          }
  166.          else
  167.          {
  168.             _loc7_ = _loc6_.ascent + _loc6_.descent;
  169.             _loc3_ = _loc7_ + 4;
  170.             _loc4_ = _loc6_.textFieldHeight;
  171.             _loc5_ = 0;
  172.             while(_loc4_ > _loc3_)
  173.             {
  174.                _loc5_ = _loc5_ + 1;
  175.                _loc4_ -= _loc3_;
  176.             }
  177.             _loc9_ = _loc5_ != 0 ? 6 + _loc7_ + _loc5_ * _loc3_ : 6 + _loc7_;
  178.             this.__priDesc.setSize(365,_loc9_);
  179.          }
  180.       }
  181.    }
  182.    function set highlight1(newHighlight)
  183.    {
  184.       _level0.showObjectSummary();
  185.       this.__highlight1 = this.attachMovie("HighlightBoxout","Highlight1",this.__nextDepth,newHighlight);
  186.       this.__highlight1.setSize(361,131);
  187.       this.__highlight1._x = IntroPage.__pageBorder + 2;
  188.       this.__highlight1._y = 138;
  189.       this.__highlight1.image = newHighlight.imagePath;
  190.       this.__nextDepth = this.__nextDepth + 1;
  191.       this.__highlightListener = new Object();
  192.       this.__highlightListener.press = function(evtObj)
  193.       {
  194.          _level0.entries.selectedIndex = evtObj.target.__target;
  195.          _level0.pageMgr.buildPage(2,_level0.dataSource[_level0.sections.selectedIndex].data[evtObj.target.__target]);
  196.       };
  197.       this.__highlight1.addEventListener("press",this.__highlightListener);
  198.       this.__highlight1.enabled = true;
  199.    }
  200.    function set highlight2(newHighlight)
  201.    {
  202.       this.__highlight2 = this.attachMovie("HighlightBoxout","Highlight2",this.__nextDepth,newHighlight);
  203.       this.__highlight2.setSize(361,131);
  204.       this.__highlight2._x = IntroPage.__pageBorder + 2;
  205.       this.__highlight2._y = this.__highlight1._y + 130 + IntroPage.__vSpacing;
  206.       this.__highlight2.image = newHighlight.imagePath;
  207.       this.__nextDepth = this.__nextDepth + 1;
  208.       this.__highlight2.addEventListener("press",this.__highlightListener);
  209.       this.__highlight2.enabled = true;
  210.    }
  211.    function set secondaryDescription(newDesc)
  212.    {
  213.       if(this.__secDesc == undefined)
  214.       {
  215.          this.__secDesc = this.createClassObject(mx.controls.TextArea,"secondaryDesc",this.__nextDepth);
  216.          this.__nextDepth = this.__nextDepth + 1;
  217.          this.__secDesc.label.selectable = false;
  218.          this.__secDesc.borderStyle = "none";
  219.          this.__secDesc.html = true;
  220.          this.__secDesc.embedFonts = true;
  221.          this.__secDesc.styleSheet = _global.textStyles;
  222.       }
  223.       if(this.__secDesc.text != newDesc)
  224.       {
  225.          this.__secDesc.text = newDesc;
  226.          this.__secDesc.setSize(365,20);
  227.       }
  228.       this.__secDesc._x = IntroPage.__pageBorder;
  229.       this.__secDesc._y = this.__highlight1._y + this.__highlight1.height + IntroPage.__vSpacing + 3;
  230.    }
  231.    function set secondaryList(newContents)
  232.    {
  233.       if(this.__secList == undefined)
  234.       {
  235.          this.__secList = this.createClassObject(mx.controls.List,"secondaryList",this.__nextDepth);
  236.          this.__nextDepth = this.__nextDepth + 1;
  237.          this.__secList.html = false;
  238.          this.__secList.embedFonts = true;
  239.          this.__secList.setStyle("styleName","footerListStyle");
  240.       }
  241.       this.__secList.dataProvider = newContents;
  242.       this.__secList._x = IntroPage.__pageBorder + 2;
  243.       this.__secList._y = this.__secDesc._y + this.__secDesc.height + IntroPage.__vSpacing;
  244.       this.__secList.vScrollPolicy = "auto";
  245.       var _loc6_ = 2;
  246.       var _loc8_ = newContents.length;
  247.       if(_loc8_ > 1)
  248.       {
  249.          var _loc10_ = this.__secDesc._y + this.__secDesc.height;
  250.          var _loc2_ = IntroPage.__maxPageHeight - _loc10_ - 2 * IntroPage.__vSpacing;
  251.          var _loc5_ = 0;
  252.          _loc5_ = _loc2_ % this.__secList.rowHeight < 4 ? Math.floor(_loc2_ / this.__secList.rowHeight) - 1 : Math.floor(_loc2_ / this.__secList.rowHeight);
  253.          _loc6_ += _loc5_ * this.__secList.rowHeight;
  254.          this.__secList.setSize(364,_loc6_);
  255.       }
  256.       else
  257.       {
  258.          this.__secList.setSize(364,this.__secList.rowHeight + 2);
  259.       }
  260.       var _loc4_ = new Object();
  261.       _loc4_.change = function(evtObj)
  262.       {
  263.          var _loc2_ = _level0.sections.selectedIndex;
  264.          var _loc3_ = evtObj.target.selectedIndex;
  265.          var _loc1_ = _level0.dataSource[_loc2_].updates[_loc3_].target;
  266.          _level0.entries.selectedIndex = _loc1_;
  267.          _level0.pageMgr.buildPage(2,_level0.dataSource[_loc2_].data[_loc1_]);
  268.       };
  269.       this.__secList.addEventListener("change",_loc4_);
  270.    }
  271.    function setLayout(Void)
  272.    {
  273.       var _loc2_ = undefined;
  274.       this.__title._y = this.__title._x = _loc2_ = 0;
  275.       _loc2_ += this.__title.height + IntroPage.__vSpacing;
  276.       if(this.__priDesc != undefined)
  277.       {
  278.          this.__priDesc._x = IntroPage.__pageBorder;
  279.          this.__priDesc._y = _loc2_;
  280.          _loc2_ += this.__priDesc.height + 125 + 2 * IntroPage.__vSpacing;
  281.       }
  282.       if(this.__secDesc != undefined)
  283.       {
  284.          this.__secDesc._x = IntroPage.__pageBorder;
  285.          this.__secDesc._y = _loc2_;
  286.          _loc2_ += this.__secDesc.height + IntroPage.__vSpacing;
  287.       }
  288.    }
  289.    function draw(Void)
  290.    {
  291.    }
  292.    function removeHTMLTags(htmlText)
  293.    {
  294.       var _loc6_ = function(txt, index)
  295.       {
  296.          return txt.indexOf("<",index);
  297.       };
  298.       var _loc8_ = function(txt, index)
  299.       {
  300.          return txt.indexOf(">",index);
  301.       };
  302.       var _loc2_ = new Array();
  303.       var _loc7_ = 0;
  304.       var _loc9_ = undefined;
  305.       var _loc10_ = undefined;
  306.       while(_loc7_ < htmlText.length)
  307.       {
  308.          _loc9_ = _loc6_(htmlText,_loc7_);
  309.          if(_loc9_ == -1)
  310.          {
  311.             break;
  312.          }
  313.          _loc10_ = _loc8_(htmlText,_loc9_);
  314.          var _loc3_ = _loc6_(htmlText,_loc10_);
  315.          while(_loc3_ == _loc10_ + 1)
  316.          {
  317.             _loc10_ = _loc8_(htmlText,_loc3_);
  318.             _loc3_ = _loc6_(htmlText,_loc10_);
  319.          }
  320.          _loc2_.push({start:_loc9_,end:_loc10_});
  321.          _loc7_ = _loc10_ + 1;
  322.       }
  323.       var _loc5_ = 0;
  324.       while(_loc5_ < _loc2_.length)
  325.       {
  326.          _loc9_ = _loc2_[_loc5_].start;
  327.          var _loc11_ = htmlText.charAt(_loc2_[_loc5_].start);
  328.          _loc10_ = _loc2_[_loc5_].end;
  329.          var _loc12_ = htmlText.charAt(_loc2_[_loc5_].end);
  330.          var _loc16_ = htmlText.substring(_loc9_ + 1,_loc10_);
  331.          _loc5_ = _loc5_ + 1;
  332.       }
  333.       if(_loc2_.length != 0)
  334.       {
  335.          var _loc18_ = "";
  336.          if(_loc2_[0].start > 0)
  337.          {
  338.             _loc18_ += htmlText.substring(0,_loc2_[0].start);
  339.          }
  340.          var _loc4_ = 0;
  341.          while(_loc4_ < _loc2_.length - 1)
  342.          {
  343.             var _loc13_ = _loc2_[_loc4_].end + 1;
  344.             var _loc15_ = _loc2_[_loc4_ + 1].start;
  345.             _loc18_ += htmlText.substring(_loc2_[_loc4_].end + 1,_loc2_[_loc4_ + 1].start);
  346.             _loc4_ = _loc4_ + 1;
  347.          }
  348.          if(_loc2_[_loc2_.length - 1].end < htmlText.length - 1)
  349.          {
  350.             _loc18_ += htmlText.substring(_loc2_[_loc2_.length - 1].end + 1);
  351.          }
  352.          return _loc18_;
  353.       }
  354.       return htmlText;
  355.    }
  356.    function sendMessage(p_msgtxt)
  357.    {
  358.       var _loc2_ = {target:this,type:"pageReady"};
  359.       _loc2_.msgtxt = p_msgtxt;
  360.       _loc2_.pageType = "IntroPage";
  361.       this.dispatchEvent(_loc2_);
  362.    }
  363. }
  364.